//-------------------------------------------------------
// Copyright (c) 
// All rights reserved.
//
// File Name: MsgWindow.h
// File Des: 窗口消息进程内/间通信 基类  创建消息循环server
// File Summary:
// Cur Version: 1.0
// Author:lzlong
// Create Data:2023-8-10
// History:
//         <Author>    <Time>        <Version>      <Des>
//      lzlong        2023-8-10     1.0
//-------------------------------------------------------
#pragma once
#include <string>
#include <windows.h>
#include "LinkNodeT.h"

class IProcessWndMessage
{
public:
    IProcessWndMessage() {};
    virtual ~IProcessWndMessage() {};
    virtual LRESULT AfterProcessWndMessage(UINT msg, WPARAM wParam, LPARAM lParam) { return S_FALSE; }
    virtual LRESULT ProcessWndMessage(UINT msg, WPARAM wParam, LPARAM lParam) = 0;
};

class CMsgWindowClass;
class CMsgWindow : public CLinkNodeT<CMsgWindow>, public IProcessWndMessage
{
public:
    CMsgWindow(const std::wstring& _name, bool bRecSameSvrNameMsg);

    virtual ~CMsgWindow();

    LPCTSTR GetWndName();

    HWND    GetHandle() const;

    LRESULT ProcessWndMessage(UINT msg, WPARAM wParam, LPARAM lParam) override;

    LRESULT AfterProcessWndMessage(UINT msg, WPARAM wParam, LPARAM lParam) override;

protected:
    std::wstring        m_strWndName;

    HWND                m_handle;
private:
    static CMsgWindowClass* ms_MsgWndCls;

    static long            ms_lMsgWndCount;

    bool                m_bRecSameSvrNameMsg;  // 接收同窗口名称的消息 因为窗口可能被同名窗口覆盖
};

